import React from 'react';
import ReactDOM from 'react-dom';
import logo from './logo.svg';
import './Home.css';
import AppBar from './components/AppBar';

function UserHomeButtonPanel() {
  let type = localStorage.getItem('user-type');
  switch (type) {
    case 'C':
      return (
        <div>
          <button onClick={() => { window.location.href = '/customer/shops' }} type="button" className="btn btn-lg btn-block btn-primary" style={{ display: 'block', width: '100%' }}>去点餐</button>
          <button onClick={() => { window.location.href = '/customer/orders' }} type="button" className="btn btn-lg btn-block btn-danger" style={{ display: 'block', width: '100%', marginLeft: '0' }}>我的订单</button>
          <button onClick={() => { window.location.href = '/customer/receive_info' }} type="button" className="btn btn-lg btn-block btn-success" style={{ display: 'block', width: '100%', marginLeft: '0' }}>收货地址</button>
        </div>
      );
    case 'B':
      return (
        <div>
          <button onClick={() => { window.location.href = '/business/shops' }} type="button" className="btn btn-lg btn-block btn-primary" style={{ display: 'block', width: '100%' }}>管理店铺</button>
          <button onClick={() => { window.location.href = '/business/orders/all' }} type="button" className="btn btn-lg btn-block btn-danger" style={{ display: 'block', width: '100%', marginLeft: '0' }}>店铺订单</button>
        </div>
      );
    case 'D':
      return (
        <div>
          <button onClick={() => { window.location.href = '/deliverer/orderplaza' }} type="button" className="btn btn-lg btn-block btn-primary" style={{ display: 'block', width: '100%' }}>接单</button>
          <button onClick={() => { window.location.href = '/deliverer/orders' }} type="button" className="btn btn-lg btn-block btn-danger" style={{ display: 'block', width: '100%', marginLeft: '0' }}>我的订单</button>
          <button onClick={() => { window.location.href = '/deliverer/pos' }} type="button" className="btn btn-lg btn-block btn-info" style={{ display: 'block', width: '100%', marginLeft: '0' }}>我的位置</button>
        </div>
      );
  }
  return (<h2>请登录或注册</h2>);
}

function Home() {
  return (
    <div>
      <AppBar></AppBar>
      <div className="container" style={{ padding: '20px 0' }}>
        <UserHomeButtonPanel></UserHomeButtonPanel>
      </div>
    </div>
  );
}

export default Home;
